 

package com.zdkj.subway.support.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.common.security.util.ObjectUtils;
import com.zdkj.subway.support.entity.SwPmReportAlter;
import com.zdkj.subway.support.service.SwPmReportAlterService;
import org.springframework.beans.BeanUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 车站原始数据录入修改报表参数表
 *
 * @author cuilei
 * @date 2020-06-01 17:19:32
 */
@RestController
@AllArgsConstructor
@RequestMapping("/swpmreportalter" )
@Api(value = "swpmreportalter", tags = "车站原始数据录入修改报表参数表管理")
public class SwPmReportAlterController {

    private final SwPmReportAlterService swPmReportAlterService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param swPmReportAlter 车站原始数据录入修改报表参数表
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public R getSwPmReportAlterPage(Page page, SwPmReportAlter swPmReportAlter) {
        return R.ok(swPmReportAlterService.page(page, Wrappers.query(swPmReportAlter)));
    }

    /**
     * 通过id查询车站原始数据录入修改报表参数表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public R getById(@PathVariable("id" ) Integer id) {
        return R.ok(swPmReportAlterService.getById(id));
    }

    /**
     * 新增车站原始数据录入修改报表参数表
     * @param swPmReportAlter 车站原始数据录入修改报表参数表
     * @return R
     */
    @ApiOperation(value = "新增车站原始数据录入修改报表参数表", notes = "新增车站原始数据录入修改报表参数表")
    @SysLog("新增车站原始数据录入修改报表参数表" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('support_sw_pm_report_alter_add')" )
    public R save(@RequestBody SwPmReportAlter swPmReportAlter) {
        SwPmReportAlter defaultObj = ObjectUtils.getDefaultObj(SwPmReportAlter.class);
        BeanUtils.copyProperties(swPmReportAlter, defaultObj,
                ObjectUtils.getNullAndEmptyPropertyNames(swPmReportAlter));
        return R.ok(swPmReportAlterService.save(defaultObj));
    }

    /**
     * 修改车站原始数据录入修改报表参数表
     * @param swPmReportAlter 车站原始数据录入修改报表参数表
     * @return R
     */
    @ApiOperation(value = "修改车站原始数据录入修改报表参数表", notes = "修改车站原始数据录入修改报表参数表")
    @SysLog("修改车站原始数据录入修改报表参数表" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('support_sw_pm_report_alter_edit')" )
    public R updateById(@RequestBody SwPmReportAlter swPmReportAlter) {
        return R.ok(swPmReportAlterService.updateById(swPmReportAlter));
    }

    /**
     * 通过id删除车站原始数据录入修改报表参数表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除车站原始数据录入修改报表参数表", notes = "通过id删除车站原始数据录入修改报表参数表")
    @SysLog("通过id删除车站原始数据录入修改报表参数表" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('support_sw_pm_report_alter_del')" )
    public R removeById(@PathVariable Integer id) {
        return R.ok(swPmReportAlterService.removeById(id));
    }

}
